package ActionListeners;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JTextField;

public class MascaraCantidadCharKeyListener implements KeyListener  {
	private int cantidad;
	public MascaraCantidadCharKeyListener(int cant){
		super();
		cantidad=cant;
	}
	@Override
	public void keyPressed(KeyEvent e) {
			
	}

	@Override
	public void keyReleased(KeyEvent e) {

		}

	@Override
	public void keyTyped(KeyEvent e) {
		 String texto=((JTextField) e.getSource()).getText();
		 int cantTexto=texto.length();
		 if(cantTexto>=cantidad){
			 e.consume();
		 }
	}



}